<template>
  <div class="navbar-con">
    <div class="navbar-box">
      <span
        class="el-icon-s-unfold navbar-icon"
        @click="TOGGLE_SIDEBAR_AC"
        :class="{ 'is-active': this.sidebar.opened }"
      ></span>
      <myBreadcrumb></myBreadcrumb>
    </div>
    <div class="navbar-xiala">
      欢迎{{ name }}登录本系统
      <el-dropdown>
        <span class="el-dropdown-link">
          <img src="@/assets/images/mz_small_icon.png" class="navbar_img" />
          <i class="el-icon-arrow-down el-icon--right"></i>
        </span>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item>首页</el-dropdown-item>
          <!-- 在element ui的组件上不能直接绑定原生事件 -->
          <el-dropdown-item @click.native="logout">退出</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
  </div>
</template>

<script>
import myBreadcrumb from "./myBreadcrumb.vue";
import { mapActions, mapGetters } from "vuex";

export default {
  name: "navbar",
  components: {
    myBreadcrumb,
  },
  methods: {
    ...mapActions(["TOGGLE_SIDEBAR_AC"]),
    logout() {
      console.log("tuichu");
      this.$store.dispatch("LogoutAC");
      //location.reload();
      this.$router.go(0);
    },
  },
  computed: {
    ...mapGetters(["sidebar", "name"]),
  },
};
</script>

<style lang="scss" scoped>
.navbar-con {
  display: flex;
  justify-content: space-between;
  flex-wrap: nowrap;
  .navbar-box {
    display: flex;
    // height: 50px;
    // line-height: 50px;
    .navbar-icon {
      margin-top: 17px;
      margin-left: 17px;
      width: 16px;
      height: 16px;
      transform: rotate(0deg);
      transition: 1s;
      transform-origin: 50% 50%;
      display: inline-block;
    }
    .is-active {
      transform: rotate(90deg);
    }
  }
  .navbar-xiala {
    margin-right: 10px;
    .navbar_img {
      width: 40px;
      height: 40px;
      margin-top: 5px;
      border-radius: 5px;
    }
  }
}
</style>